package com.taxshare.purchaser.service;

import cn.hutool.core.lang.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.taxshare.purchaser.entity.ElectronicledgerEntity;
import com.taxshare.purchaser.entity.InterfaceLogEntity;
import com.taxshare.purchaser.mapper.ElectronicledgerMapper;
import com.taxshare.purchaser.mapper.InterfaceLogMapper;
import com.taxshare.tools.util.UUIDUitl;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.text.DecimalFormat;

/**
 * @ClassName: InterfaceLogService
 * @Description:
 * @author: luozhongyi
 * @date: 2021/4/12 14:14
 */
@Service
public class InterfaceLogService extends ServiceImpl<InterfaceLogMapper, InterfaceLogEntity> {

    @Async
    public void insertInterfaceLog(String method, String reqContent,String respContent,int time){
        DecimalFormat df = new DecimalFormat("#0.00");
        InterfaceLogEntity entity = new InterfaceLogEntity();
        entity.setUuid(UUIDUitl.UUID32());
        entity.setMethod(method);
        entity.setReqContent(reqContent);
        entity.setRespContent(respContent);
        entity.setTime(df.format((double)time/1000));
        baseMapper.insert(entity);
    }
}
